from django.contrib.auth.forms import UserCreationForm
from django.views.generic.simple import redirect_to
from django.core.urlresolvers import reverse
from kalapankki import utils

def register(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect_to(request, reverse("login"))
    else:
        form = UserCreationForm()
    return utils.render_with_request_context(request, 'registration/register.html', {'form' : form})